<?php
class iJMessages {
    
    private static $message;
    private static $description;
    private static $display = false;
    private static $type;
    private static $loaded = false;
    public function __construct() {
        
    }
    
    public static function display($type, $message, $description = '') {
      $iJLanguages = iJFactory::singleton('iJLanguages');
      if(!self::$loaded) {
        $iJLanguages->load(MESAGES_LANGUAGE_FILE);
        self::$loaded = true;
      }
      
      self::$display = true;
      self::$type        = strtolower($type);
      
      self::$message     = $iJLanguages->getTocken($message);
      
      if(!empty($description)) {
          self::$description = $iJLanguages->getTocken($description);
      } else {
          self::$description = $iJLanguages->getTocken('action_' . self::$type);
      }  
  
    }
    
    public static function ajaxDisplay($type, $message, $description = '') {
      $iJLanguages = iJFactory::singleton('iJLanguages');
      if(!self::$loaded) {
        $iJLanguages->load(MESAGES_LANGUAGE_FILE);
        self::$loaded = true;
      }
      
      self::$display = true;
      self::$type        = strtolower($type);
      
      self::$message     = $iJLanguages->getTocken($message);
      
      if(!empty($description)) {
          self::$description = $iJLanguages->getTocken($description);
      } else {
          self::$description = $iJLanguages->getTocken('action_' . self::$type);
      }  
      
      $mes['type']        = $type;
      $mes['message']     = self::$message;
      $mes['description'] = self::$description;
      
      return $mes;
      
    }
    
    public static function getMessage() {
        $tokens = array();
        $tokens['message'] = self::$message;
        $tokens['description'] = self::$description;
        $tokens['type'] = self::$type;
        if(self::$display) {
            $tokens['display'] = true;
        }
        return $tokens;
    }
    
    
    
    
    
    
}
?>